﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using HP.Cachalote.DataModels;

namespace HP.Cachalote.Repositories.EntityFramework.Mappings
{
    public class TodoLabelMap : EntityTypeConfiguration<TodoLabel>
    {
        public TodoLabelMap()
        {
            //Primary key
            this.HasKey(l => l.ID);

            //Mapping
            this.ToTable("Labels");
            this.Property(l => l.ID).HasColumnName("ID");
            this.Property(l => l.ParentID).HasColumnName("ParentID");
            this.Property(l => l.Name).HasColumnName("Name");
            this.Property(l => l.Icon).HasColumnName("Icon");
            this.Property(l => l.OrderIndex).HasColumnName("OrderIndex");

            //ForeignKey
            this.HasOptional(l => l.Parent)
                .WithMany(l => l.SubLabels)
                .HasForeignKey(l => l.ParentID);
        }
    }
}
